/*
 * @Description: 
 * @Author: kilomChou
 * @Date: 2021-05-13 00:43:33
 * @LastEditTime: 2021-05-20 10:24:41
 * @LastEditors: Please set LastEditors
 */
import BaseEntity from "./BaseEntity";
import { IAngCircle, Vec2 } from "../../core/vec2/Vec2";
import Vec2Operator from "../../core/vec2/Vec2Operator";
const [v2, v2op] = [Vec2, new Vec2Operator()];

/** 圆形实体 */
export default abstract class CircleEntity extends BaseEntity implements IAngCircle {

    x: number;
    y: number;
    r: number;
    ang: number;
    /** 宽度 */
    get w() { return this.r * 2; }
    set w(w) { this.r = w * 0.5; }
    /** 朝向弧度 */
    get rad() { return v2.ang2rad(this.ang); }
    /** 二维向量操作者(使用后会覆盖前一个使用的) */
    get op() { return v2op.setCirObj(this); }
    /** 是否撞墙 */
    get isColWall() { return !v2.isCirInRect(this, this.world.rect); }
}